const Koa = require('koa')
const routers = require('./routers')
const routerResponse = require('./middleware/routerResponse')
const bodyParser = require('koa-bodyparser');
const config = require('./config/default')
const jwt = require('koa-jwt');
require('./db')

const app = new Koa()

app.use(routerResponse())

app.use(bodyParser())

// 排除不需要jwt验证的地址
app.use(jwt({secret: config.secret}).unless({
  path:[/^\/users\/login/, /^\/users\/create/]
}))


routers(app)


app.listen(3000, () => {
  console.log('已打开3000端口')
})
